home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / System / CDIconKiller 1.4.1 / sources / CDIconKiller.c < prev    next >
Encoding:
Text File  |  1997-04-29  |  7.5 KB  |  159 lines  |  [TEXT/CWIE]

  1. #ifndef __Assembler__
  2. #include    <Assembler.h>
  3. #endif
  4.  
  5. #include    "TrapAvailable.h"
  6. /*
  7. ; CDIconKiller © 1994, 1997 Quinn & Peter N Lewis, Fabrizio Oddone
  8. ; Version 1.0 written in 4 hours from 02:00 to 05:30 18/June/94
  9.  
  10. bug fixes, CD driver string in resource (suggested by Quinn),
  11. asm tweaks, cdev trickery, etc.
  12. (version 1.1 thru 1.4.x) by Fabrizio Oddone
  13.  
  14. ; Patches GetCatInfo, tests for Custom Icon attribute on
  15. ; CD-ROM files/folders, and clears it.
  16.  
  17. ; Detailed description:
  18.  
  19. ; now runs as a cdev so the patch affects only the Finder
  20. ; since there is no user interface, we can retain the old icon
  21.  
  22. ; macDev time:
  23. ;    check if we are running under System 7 or later
  24. ;        check if the patch is already installed
  25. ;        load the resource containing the driver strings
  26. ;        patch GetCatInfo
  27.  
  28. ; initDev time:
  29. ;    we are done, quit silently
  30.  
  31. ; GetCatInfo patch:
  32. ;   Test for GetCatInfo selector on _HFSDispatch, do nothing otherwise
  33. ;   Call thru
  34. ;   Return immediately on error or async call
  35. ;   Return immediately unless Custom Icon bit set
  36. ;   Walk the volume queue looking for the vRefNum of the GetCatInfo
  37. ;   If we don't find it, we leave
  38. ;   If the command key is down, we leave
  39. ;   We determine whether the driver refnum is known (yes/no custom icons)
  40. ;   If "no", then clear the custom icon bit
  41. ;   If "yes", then leave
  42. ;   If the driver refnum is NOT known, we scan the driver queue and update our lists
  43.  
  44.     include    'sysequ.a'
  45.     include    'fsequ.a'
  46.     include    'traps.a'
  47.  
  48. ; procedure ShowIcon (id: integer; delta_x: integer);
  49.     import    ShowIcon
  50. */
  51. //main    proc    export
  52.  
  53. //extern pascal void ShowIcon(short iconID, short pixels);
  54. static void mypatch(void);
  55.  
  56. //#define patchSize    (EndHFSDispatch - OurHFSDispatch)
  57. #define    patchSize    (526)    // because of CodeWarrior asm limitations
  58. #define    HFSDispatchTrapNum    0x60
  59.  
  60. pascal long main(short message, short /*item*/, short /*numItems*/, short /*cPanelID*/, EventRecord */*theEvent*/, long cdevValue, DialogPtr /*cpDialog*/)
  61. {
  62. long    resp;
  63.  
  64. if (cdevValue) {
  65.     switch (message) {
  66.         case initDev:
  67.             return cdevGenErr;
  68.             break;
  69.         ca
  70. notram:
  71.     move.w    d3,d4
  72.     sub.w    0x1d2,d4    // calc driver refnum -(unit num+1) LMGetUnitTableEntryCount()
  73.     subq.w    #1,d4
  74.     tst.b    d5
  75.     bne.s    firsttime
  76.     move.w    d4,d1
  77.     bsr    finddriverdontwantcustomicons
  78.     bne.s    endloop
  79.     bsr    finddriverwantcustomicons
  80.     bne.s    endloop
  81. firsttime:
  82.     lea    struct (DRVRHeader.drvrName)(a0),a0
  83.     moveq    #0,d2
  84.     move.b    (a0)+,d2
  85.     swap    d2
  86.     bsr    cmpallstrings
  87.     bne.s    endloopsavedriver
  88.     movea.l    a3,a1
  89.     bra.s    commonpart
  90. endloopsavedriver:
  91.     movea.l    a4,a1
  92. commonpart:
  93.     movea.l    (a1),a0
  94.     move.w    d4,(a0)+    // remember driver refnum
  95.     move.l    a0,(a1)
  96. endloop:
  97.     subq.w    #1,d3
  98.     bne    loop
  99. plainexit:
  100.     movem.l    (sp)+,a0-a4/a6/d1/d3-d5
  101.     rts
  102.  
  103. // input: a0 string, d2 (already in hi word) length
  104. // output: sets the flags
  105. // registers are saved&restored by the caller
  106. cmpallstrings:
  107.     movea.l    stringH,a6
  108.     movea.l    (a6),a6
  109.     move.w    (a6)+,d1
  110.     andi    #0xB,CCR
  111.     bra.s    thedbcc
  112. cmploop:
  113.     move.l    d2,d0
  114.     move.b    (a6)+,d0
  115.     movea.l    a6,a1
  116.     adda.w    d0,a6
  117.     _CmpString
  118. thedbcc:
  119.     dbeq    d1,cmploop
  120. cmpexit:
  121.     rts
  122.  
  123. skipthesedrivers:
  124.     ds.w    15
  125. lastskipthesedrivers:
  126.     dc.w    -1
  127. otherdrivers:
  128.     ds.w    63
  129. lastotherdrivers:
  130.     dc.w    -1
  131. nextfreedontwant:
  132.     dc.l    0
  133. nextfreewant:
  134.     dc.l    0
  135. stringH:
  136.     dc.l    0
  137. oldHFSDispatch:
  138.     dc.l    0xffffffff
  139. EndHFSDispatch:
  140.  
  141. //    string    pascal
  142.  
  143. }
  144. //    endp
  145.     
  146. //    end
  147.     
  148. /*
  149. asm -wb "{active}"
  150. (evaluate "{active}" =~ "/(?*:)®1(?*)/" )> dev:null
  151. (evaluate "{active}" =~ "/(?*)®2.a/" )> dev:null
  152. link -rt INIT=128 -ra =ressysheap,reslocked -t INIT -c CDik -o "{®2}" "{active}.o" "{®1}ShowIcon.o"
  153. setfile -a B "{®2}"
  154.  
  155.  
  156.  
  157. dumpobj "{®1}SHOWICON.o"
  158. */
  159.